<template>
  <div class="admin-home">
    <!-- 欢迎区域 -->
    <div class="welcome-section">
      <div class="welcome-content">
        <h1 class="welcome-title">欢迎回来，{{ userInfo.username }}</h1>
        <p class="welcome-subtitle">今天是 {{ formatDate(new Date(), 'YYYY年MM月DD日 dddd') }}</p>
      </div>
      <div class="welcome-actions">
        <el-button type="primary" @click="$router.push('/admin/system/settings')">
          <el-icon><Setting /></el-icon>
          系统设置
        </el-button>
        <el-button @click="$router.push('/admin/system/logs')">
          <el-icon><Document /></el-icon>
          查看日志
        </el-button>
      </div>
    </div>

    <!-- 统计卡片 -->
    <el-row :gutter="20" class="stats-row">
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card" shadow="hover" @click="$router.push('/admin/users/students')">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.totalStudents }}</div>
              <div class="stats-label">学生用户</div>
              <div class="stats-trend">
                <span class="trend-value positive">+{{ stats.newStudentsToday }}</span>
                <span class="trend-text">今日新增</span>
              </div>
            </div>
            <el-icon class="stats-icon"><User /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card" shadow="hover" @click="$router.push('/admin/users/organizers')">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.totalOrganizers }}</div>
              <div class="stats-label">组织者</div>
              <div class="stats-trend">
                <span class="trend-value positive">+{{ stats.newOrganizersToday }}</span>
                <span class="trend-text">今日新增</span>
              </div>
            </div>
            <el-icon class="stats-icon organizers"><UserFilled /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card" shadow="hover" @click="$router.push('/admin/activities')">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.totalActivities }}</div>
              <div class="stats-label">活动总数</div>
              <div class="stats-trend">
                <span class="trend-value positive">+{{ stats.newActivitiesToday }}</span>
                <span class="trend-text">今日新增</span>
              </div>
            </div>
            <el-icon class="stats-icon activities"><Calendar /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card" shadow="hover" @click="$router.push('/admin/registrations')">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.totalRegistrations }}</div>
              <div class="stats-label">报名总数</div>
              <div class="stats-trend">
                <span class="trend-value positive">+{{ stats.newRegistrationsToday }}</span>
                <span class="trend-text">今日新增</span>
              </div>
            </div>
            <el-icon class="stats-icon registrations"><Tickets /></el-icon>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <!-- 左侧内容 -->
      <el-col :xs="24" :lg="16">
        <!-- 系统状态 -->
        <el-card class="system-status-card">
          <template #header>
            <div class="card-header">
              <div class="header-title">
                <el-icon><Monitor /></el-icon>
                <span>系统状态</span>
              </div>
              <el-button type="text" @click="refreshSystemStatus">
                <el-icon><Refresh /></el-icon>
                刷新
              </el-button>
            </div>
          </template>
          
          <div class="system-status">
            <div class="status-item">
              <div class="status-info">
                <div class="status-label">服务器状态</div>
                <div class="status-value">
                  <el-tag :type="systemStatus.server === 'running' ? 'success' : 'danger'" size="small">
                    {{ systemStatus.server === 'running' ? '运行中' : '异常' }}
                  </el-tag>
                </div>
              </div>
              <div class="status-detail">CPU: {{ systemStatus.cpu }}% | 内存: {{ systemStatus.memory }}%</div>
            </div>
            
            <div class="status-item">
              <div class="status-info">
                <div class="status-label">数据库状态</div>
                <div class="status-value">
                  <el-tag :type="systemStatus.database === 'connected' ? 'success' : 'danger'" size="small">
                    {{ systemStatus.database === 'connected' ? '已连接' : '连接异常' }}
                  </el-tag>
                </div>
              </div>
              <div class="status-detail">连接数: {{ systemStatus.dbConnections }} | 响应时间: {{ systemStatus.dbResponseTime }}ms</div>
            </div>
            
            <div class="status-item">
              <div class="status-info">
                <div class="status-label">缓存状态</div>
                <div class="status-value">
                  <el-tag :type="systemStatus.cache === 'running' ? 'success' : 'warning'" size="small">
                    {{ systemStatus.cache === 'running' ? '正常' : '异常' }}
                  </el-tag>
                </div>
              </div>
              <div class="status-detail">命中率: {{ systemStatus.cacheHitRate }}% | 内存使用: {{ systemStatus.cacheMemory }}MB</div>
            </div>
          </div>
        </el-card>
        
        <!-- 最新活动 -->
        <el-card class="recent-activities-card">
          <template #header>
            <div class="card-header">
              <div class="header-title">
                <el-icon><Calendar /></el-icon>
                <span>最新活动</span>
              </div>
              <el-button type="text" @click="$router.push('/admin/activities')">
                查看全部
              </el-button>
            </div>
          </template>
          
          <div v-if="loadingActivities" class="loading-container">
            <el-skeleton :rows="3" animated />
          </div>
          
          <div v-else-if="recentActivities.length === 0" class="empty-container">
            <el-empty description="暂无活动" :image-size="60" />
          </div>
          
          <div v-else class="activities-list">
            <div 
              v-for="activity in recentActivities" 
              :key="activity.id"
              class="activity-item"
              @click="viewActivityDetail(activity.id)"
            >
              <div class="activity-info">
                <div class="activity-title">{{ activity.title }}</div>
                <div class="activity-meta">
                  <span class="meta-item">
                    <el-icon><User /></el-icon>
                    {{ activity.organizerName }}
                  </span>
                  <span class="meta-item">
                    <el-icon><Clock /></el-icon>
                    {{ formatDate(activity.startTime, 'MM-DD HH:mm') }}
                  </span>
                  <span class="meta-item">
                    <el-icon><Location /></el-icon>
                    {{ activity.location }}
                  </span>
                </div>
              </div>
              <div class="activity-status">
                <el-tag :type="getActivityStatusType(activity.status)" size="small">
                  {{ getActivityStatusText(activity.status) }}
                </el-tag>
              </div>
            </div>
          </div>
        </el-card>
        
        <!-- 数据趋势图 -->
        <el-card class="chart-card">
          <template #header>
            <div class="card-header">
              <div class="header-title">
                <el-icon><TrendCharts /></el-icon>
                <span>数据趋势</span>
              </div>
              <el-radio-group v-model="chartPeriod" size="small" @change="loadChartData">
                <el-radio-button label="week">最近7天</el-radio-button>
                <el-radio-button label="month">最近30天</el-radio-button>
              </el-radio-group>
            </div>
          </template>
          
          <div class="chart-container">
            <div v-if="loadingChart" class="loading-container">
              <el-skeleton :rows="4" animated />
            </div>
            <div v-else class="trend-chart">
              <!-- 这里可以集成图表库如 ECharts -->
              <div class="chart-mock">
                <div class="chart-legend">
                  <div class="legend-item">
                    <div class="legend-color users"></div>
                    <span>用户注册</span>
                  </div>
                  <div class="legend-item">
                    <div class="legend-color activities"></div>
                    <span>活动创建</span>
                  </div>
                  <div class="legend-item">
                    <div class="legend-color registrations"></div>
                    <span>活动报名</span>
                  </div>
                </div>
                <div class="chart-content">
                  <div class="chart-bars">
                    <div 
                      v-for="(item, index) in chartData" 
                      :key="index"
                      class="bar-group"
                    >
                      <div class="bar users" :style="{ height: `${item.users * 2}px` }">
                        <div class="bar-value">{{ item.users }}</div>
                      </div>
                      <div class="bar activities" :style="{ height: `${item.activities * 8}px` }">
                        <div class="bar-value">{{ item.activities }}</div>
                      </div>
                      <div class="bar registrations" :style="{ height: `${item.registrations * 1.5}px` }">
                        <div class="bar-value">{{ item.registrations }}</div>
                      </div>
                    </div>
                  </div>
                  <div class="chart-labels">
                    <span v-for="(item, index) in chartData" :key="index" class="chart-label">
                      {{ item.label }}
                    </span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </el-card>
      </el-col>
      
      <!-- 右侧内容 -->
      <el-col :xs="24" :lg="8">
        <!-- 待处理事项 -->
        <el-card class="todo-card">
          <template #header>
            <div class="header-title">
              <el-icon><List /></el-icon>
              <span>待处理事项</span>
            </div>
          </template>
          
          <div v-if="loadingTodos" class="loading-container">
            <el-skeleton :rows="3" animated />
          </div>
          
          <div v-else-if="todoList.length === 0" class="empty-container">
            <el-empty description="暂无待处理事项" :image-size="60" />
          </div>
          
          <div v-else class="todo-list">
            <div 
              v-for="todo in todoList" 
              :key="todo.id"
              class="todo-item"
              @click="handleTodoClick(todo)"
            >
              <div class="todo-content">
                <div class="todo-title">{{ todo.title }}</div>
                <div class="todo-desc">{{ todo.description }}</div>
                <div class="todo-time">{{ formatDate(todo.createdAt, 'MM-DD HH:mm') }}</div>
              </div>
              <div class="todo-priority">
                <el-tag :type="getPriorityType(todo.priority)" size="small">
                  {{ getPriorityText(todo.priority) }}
                </el-tag>
              </div>
            </div>
          </div>
        </el-card>
        
        <!-- 系统公告 -->
        <el-card class="announcement-card">
          <template #header>
            <div class="card-header">
              <div class="header-title">
                <el-icon><Bell /></el-icon>
                <span>系统公告</span>
              </div>
              <el-button type="text" @click="showAnnouncementDialog">
                <el-icon><Plus /></el-icon>
                发布公告
              </el-button>
            </div>
          </template>
          
          <div v-if="loadingAnnouncements" class="loading-container">
            <el-skeleton :rows="2" animated />
          </div>
          
          <div v-else-if="announcements.length === 0" class="empty-container">
            <el-empty description="暂无公告" :image-size="60" />
          </div>
          
          <div v-else class="announcement-list">
            <div 
              v-for="announcement in announcements" 
              :key="announcement.id"
              class="announcement-item"
            >
              <div class="announcement-content">
                <div class="announcement-title">{{ announcement.title }}</div>
                <div class="announcement-desc">{{ announcement.content }}</div>
                <div class="announcement-time">{{ formatDate(announcement.createdAt, 'MM-DD HH:mm') }}</div>
              </div>
              <div class="announcement-actions">
                <el-button type="text" size="small" @click="editAnnouncement(announcement)">
                  编辑
                </el-button>
                <el-button type="text" size="small" @click="deleteAnnouncement(announcement.id)">
                  删除
                </el-button>
              </div>
            </div>
          </div>
        </el-card>
        
        <!-- 快捷操作 -->
        <el-card class="quick-actions-card">
          <template #header>
            <div class="header-title">
              <el-icon><Operation /></el-icon>
              <span>快捷操作</span>
            </div>
          </template>
          
          <div class="quick-actions">
            <div class="action-item" @click="$router.push('/admin/users/students')">
              <el-icon class="action-icon"><User /></el-icon>
              <span class="action-text">用户管理</span>
            </div>
            
            <div class="action-item" @click="$router.push('/admin/activities')">
              <el-icon class="action-icon"><Calendar /></el-icon>
              <span class="action-text">活动管理</span>
            </div>
            
            <div class="action-item" @click="$router.push('/admin/system/settings')">
              <el-icon class="action-icon"><Setting /></el-icon>
              <span class="action-text">系统设置</span>
            </div>
            
            <div class="action-item" @click="$router.push('/admin/statistics')">
              <el-icon class="action-icon"><DataAnalysis /></el-icon>
              <span class="action-text">数据统计</span>
            </div>
            
            <div class="action-item" @click="$router.push('/admin/system/logs')">
              <el-icon class="action-icon"><Document /></el-icon>
              <span class="action-text">系统日志</span>
            </div>
            
            <div class="action-item" @click="$router.push('/admin/system/backup')">
              <el-icon class="action-icon"><FolderOpened /></el-icon>
              <span class="action-text">数据备份</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 发布公告对话框 -->
    <el-dialog
      v-model="announcementDialogVisible"
      :title="announcementMode === 'create' ? '发布公告' : '编辑公告'"
      width="600px"
      @close="resetAnnouncementForm"
    >
      <el-form
        ref="announcementFormRef"
        :model="announcementForm"
        :rules="announcementRules"
        label-width="80px"
      >
        <el-form-item label="标题" prop="title">
          <el-input v-model="announcementForm.title" placeholder="请输入公告标题" />
        </el-form-item>
        
        <el-form-item label="内容" prop="content">
          <el-input 
            v-model="announcementForm.content" 
            type="textarea" 
            :rows="4"
            placeholder="请输入公告内容"
          />
        </el-form-item>
        
        <el-form-item label="优先级" prop="priority">
          <el-select v-model="announcementForm.priority" placeholder="选择优先级">
            <el-option label="普通" value="normal" />
            <el-option label="重要" value="important" />
            <el-option label="紧急" value="urgent" />
          </el-select>
        </el-form-item>
      </el-form>
      
      <template #footer>
        <el-button @click="announcementDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="submitAnnouncement" :loading="submittingAnnouncement">
          {{ announcementMode === 'create' ? '发布' : '保存' }}
        </el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
import { formatDate } from '@/utils'
import { ElMessage, ElMessageBox } from 'element-plus'
import api from '@/utils/api'
import {
  Setting,
  Document,
  User,
  UserFilled,
  Calendar,
  Tickets,
  Monitor,
  Refresh,
  Clock,
  Location,
  TrendCharts,
  List,
  Bell,
  Plus,
  Operation,
  DataAnalysis,
  FolderOpened
} from '@element-plus/icons-vue'

const router = useRouter()
const userStore = useUserStore()

const loadingActivities = ref(false)
const loadingChart = ref(false)
const loadingTodos = ref(false)
const loadingAnnouncements = ref(false)
const announcementDialogVisible = ref(false)
const announcementMode = ref('create')
const submittingAnnouncement = ref(false)
const announcementFormRef = ref()

const chartPeriod = ref('week')

const userInfo = reactive({
  username: userStore.userInfo?.username || 'Admin'
})

const stats = reactive({
  totalStudents: 0,
  totalOrganizers: 0,
  totalActivities: 0,
  totalRegistrations: 0,
  newStudentsToday: 0,
  newOrganizersToday: 0,
  newActivitiesToday: 0,
  newRegistrationsToday: 0
})

const systemStatus = reactive({
  server: 'running',
  database: 'connected',
  cache: 'running',
  cpu: 0,
  memory: 0,
  dbConnections: 0,
  dbResponseTime: 0,
  cacheHitRate: 0,
  cacheMemory: 0
})

const recentActivities = ref([])
const chartData = ref([])
const todoList = ref([])
const announcements = ref([])

const announcementForm = reactive({
  id: null,
  title: '',
  content: '',
  priority: 'normal'
})

const announcementRules = {
  title: [
    { required: true, message: '请输入公告标题', trigger: 'blur' }
  ],
  content: [
    { required: true, message: '请输入公告内容', trigger: 'blur' }
  ],
  priority: [
    { required: true, message: '请选择优先级', trigger: 'change' }
  ]
}

const getActivityStatusType = (status) => {
  const typeMap = {
    draft: 'info',
    published: 'success',
    ongoing: 'warning',
    ended: '',
    cancelled: 'danger'
  }
  return typeMap[status] || ''
}

const getActivityStatusText = (status) => {
  const textMap = {
    draft: '草稿',
    published: '已发布',
    ongoing: '进行中',
    ended: '已结束',
    cancelled: '已取消'
  }
  return textMap[status] || status
}

const getPriorityType = (priority) => {
  const typeMap = {
    normal: '',
    important: 'warning',
    urgent: 'danger'
  }
  return typeMap[priority] || ''
}

const getPriorityText = (priority) => {
  const textMap = {
    normal: '普通',
    important: '重要',
    urgent: '紧急'
  }
  return textMap[priority] || priority
}

const loadStats = async () => {
  try {
    const response = await api.get('/admin/dashboard/stats')
    const data = response.data.data
    
    Object.assign(stats, data)
    
  } catch (error) {
    console.error('加载统计数据失败:', error)
  }
}

const loadSystemStatus = async () => {
  try {
    const response = await api.get('/admin/dashboard/system-status')
    const data = response.data.data
    
    Object.assign(systemStatus, data)
    
  } catch (error) {
    console.error('加载系统状态失败:', error)
  }
}

const refreshSystemStatus = () => {
  loadSystemStatus()
  ElMessage.success('系统状态已刷新')
}

const loadRecentActivities = async () => {
  try {
    loadingActivities.value = true
    
    const response = await api.get('/admin/dashboard/recent-activities', {
      params: { size: 5 }
    })
    recentActivities.value = response.data.data || []
    
  } catch (error) {
    console.error('加载最新活动失败:', error)
  } finally {
    loadingActivities.value = false
  }
}

const loadChartData = async () => {
  try {
    loadingChart.value = true
    
    const response = await api.get('/admin/dashboard/trend-data', {
      params: { period: chartPeriod.value }
    })
    chartData.value = response.data.data || []
    
    // 模拟数据
    if (chartData.value.length === 0) {
      const labels = chartPeriod.value === 'week' 
        ? ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
        : ['第1周', '第2周', '第3周', '第4周']
      
      chartData.value = labels.map(label => ({
        label,
        users: Math.floor(Math.random() * 50) + 10,
        activities: Math.floor(Math.random() * 10) + 1,
        registrations: Math.floor(Math.random() * 100) + 20
      }))
    }
    
  } catch (error) {
    console.error('加载图表数据失败:', error)
  } finally {
    loadingChart.value = false
  }
}

const loadTodoList = async () => {
  try {
    loadingTodos.value = true
    
    const response = await api.get('/admin/dashboard/todos', {
      params: { size: 10 }
    })
    todoList.value = response.data.data || []
    
  } catch (error) {
    console.error('加载待处理事项失败:', error)
  } finally {
    loadingTodos.value = false
  }
}

const loadAnnouncements = async () => {
  try {
    loadingAnnouncements.value = true
    
    const response = await api.get('/admin/dashboard/announcements', {
      params: { size: 5 }
    })
    announcements.value = response.data.data || []
    
  } catch (error) {
    console.error('加载公告失败:', error)
  } finally {
    loadingAnnouncements.value = false
  }
}

const viewActivityDetail = (id) => {
  router.push(`/admin/activities/${id}`)
}

const handleTodoClick = (todo) => {
  // 根据待办事项类型跳转到相应页面
  switch (todo.type) {
    case 'user_approval':
      router.push('/admin/users/organizers')
      break
    case 'activity_review':
      router.push('/admin/activities')
      break
    case 'system_maintenance':
      router.push('/admin/system/settings')
      break
    default:
      ElMessage.info('功能开发中...')
  }
}

const showAnnouncementDialog = () => {
  announcementMode.value = 'create'
  resetAnnouncementForm()
  announcementDialogVisible.value = true
}

const editAnnouncement = (announcement) => {
  announcementMode.value = 'edit'
  Object.assign(announcementForm, {
    id: announcement.id,
    title: announcement.title,
    content: announcement.content,
    priority: announcement.priority
  })
  announcementDialogVisible.value = true
}

const resetAnnouncementForm = () => {
  Object.assign(announcementForm, {
    id: null,
    title: '',
    content: '',
    priority: 'normal'
  })
  if (announcementFormRef.value) {
    announcementFormRef.value.resetFields()
  }
}

const submitAnnouncement = async () => {
  try {
    await announcementFormRef.value.validate()
    
    submittingAnnouncement.value = true
    
    if (announcementMode.value === 'create') {
      await api.post('/admin/announcements', announcementForm)
      ElMessage.success('公告发布成功')
    } else {
      await api.put(`/admin/announcements/${announcementForm.id}`, announcementForm)
      ElMessage.success('公告更新成功')
    }
    
    announcementDialogVisible.value = false
    loadAnnouncements()
    
  } catch (error) {
    if (error.response?.data?.message) {
      ElMessage.error(error.response.data.message)
    } else {
      ElMessage.error('操作失败')
    }
  } finally {
    submittingAnnouncement.value = false
  }
}

const deleteAnnouncement = async (id) => {
  try {
    await ElMessageBox.confirm(
      '确定要删除这条公告吗？',
      '确认删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    await api.delete(`/admin/announcements/${id}`)
    ElMessage.success('删除成功')
    loadAnnouncements()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('删除失败')
    }
  }
}

onMounted(() => {
  loadStats()
  loadSystemStatus()
  loadRecentActivities()
  loadChartData()
  loadTodoList()
  loadAnnouncements()
})
</script>

<style scoped>
.admin-home {
  max-width: 1400px;
  margin: 0 auto;
}

.welcome-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  color: white;
}

.welcome-content {
  flex: 1;
}

.welcome-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.welcome-subtitle {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
}

.welcome-actions {
  display: flex;
  gap: 12px;
  margin-left: 20px;
}

.stats-row {
  margin-bottom: 24px;
}

.stats-card {
  cursor: pointer;
  transition: transform 0.3s ease;
}

.stats-card:hover {
  transform: translateY(-2px);
}

.stats-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.stats-info {
  flex: 1;
}

.stats-number {
  font-size: 24px;
  font-weight: 700;
  color: #303133;
  margin-bottom: 4px;
}

.stats-label {
  font-size: 14px;
  color: #909399;
  margin-bottom: 8px;
}

.stats-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.trend-value.positive {
  color: #67c23a;
}

.trend-text {
  color: #909399;
}

.stats-icon {
  font-size: 28px;
  opacity: 0.3;
  color: #409eff;
}

.stats-icon.organizers {
  color: #67c23a;
}

.stats-icon.activities {
  color: #e6a23c;
}

.stats-icon.registrations {
  color: #f56c6c;
}

.system-status-card,
.recent-activities-card,
.chart-card,
.todo-card,
.announcement-card,
.quick-actions-card {
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #303133;
}

.system-status {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.status-item {
  padding: 16px;
  background: #f8f9fa;
  border-radius: 6px;
}

.status-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.status-label {
  font-weight: 600;
  color: #303133;
}

.status-detail {
  font-size: 12px;
  color: #606266;
}

.loading-container,
.empty-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 120px;
}

.activities-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-radius: 6px;
  background: #f8f9fa;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.activity-item:hover {
  background: #e9ecef;
}

.activity-info {
  flex: 1;
}

.activity-title {
  font-weight: 600;
  color: #303133;
  margin-bottom: 4px;
}

.activity-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #606266;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chart-container {
  height: 300px;
  padding: 20px 0;
}

.trend-chart,
.chart-mock {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #606266;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-color.users {
  background: #409eff;
}

.legend-color.activities {
  background: #67c23a;
}

.legend-color.registrations {
  background: #e6a23c;
}

.chart-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.chart-bars {
  display: flex;
  align-items: end;
  justify-content: space-around;
  height: 200px;
  padding: 0 20px;
}

.bar-group {
  display: flex;
  gap: 4px;
  align-items: end;
}

.bar {
  width: 16px;
  border-radius: 2px 2px 0 0;
  position: relative;
  min-height: 10px;
  display: flex;
  align-items: end;
  justify-content: center;
}

.bar.users {
  background: linear-gradient(to top, #409eff, #79bbff);
}

.bar.activities {
  background: linear-gradient(to top, #67c23a, #95d475);
}

.bar.registrations {
  background: linear-gradient(to top, #e6a23c, #eebe77);
}

.bar-value {
  position: absolute;
  top: -16px;
  font-size: 10px;
  color: #606266;
  font-weight: 600;
}

.chart-labels {
  display: flex;
  justify-content: space-around;
  padding: 10px 20px 0;
}

.chart-label {
  font-size: 12px;
  color: #909399;
}

.todo-list,
.announcement-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.todo-item,
.announcement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-radius: 6px;
  background: #f8f9fa;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.todo-item:hover,
.announcement-item:hover {
  background: #e9ecef;
}

.todo-content,
.announcement-content {
  flex: 1;
}

.todo-title,
.announcement-title {
  font-weight: 600;
  color: #303133;
  margin-bottom: 4px;
  font-size: 14px;
}

.todo-desc,
.announcement-desc {
  font-size: 12px;
  color: #606266;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.todo-time,
.announcement-time {
  font-size: 12px;
  color: #909399;
}

.announcement-actions {
  display: flex;
  gap: 8px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-radius: 6px;
  background: #f8f9fa;
  cursor: pointer;
  transition: all 0.3s ease;
}

.action-item:hover {
  background: #e9ecef;
  transform: translateY(-2px);
}

.action-icon {
  font-size: 24px;
  color: #409eff;
}

.action-text {
  font-size: 12px;
  color: #606266;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .welcome-section {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .welcome-actions {
    margin-left: 0;
    flex-direction: column;
  }
  
  .stats-trend {
    flex-direction: column;
    gap: 2px;
  }
  
  .chart-legend {
    flex-direction: column;
    gap: 8px;
  }
  
  .chart-bars {
    padding: 0 10px;
  }
  
  .bar {
    width: 12px;
  }
  
  .activity-meta {
    flex-direction: column;
    gap: 4px;
  }
  
  .quick-actions {
    grid-template-columns: repeat(3, 1fr);
  }
}
</style>